import docx
from docx.shared import Inches
from PIL import Image

import os
folder_path = '/Users/zhangxiangbin/Desktop/KID2'
document = docx.Document()
for filename in os.listdir(folder_path):
    if filename.endswith(".jpeg") or filename.endswith(".HEIC"):
        img_path = os.path.join(folder_path, filename)
        document.add_picture(img_path, width=Inches(2))
document.save("output.docx")